const HOST = require('../../../config.js').host

var app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    prizes:[],
  
  }, 
  goHomePage() //进入首页
  {
    wx.switchTab({
      url: '../../home/home',
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this
    this.getPrizeList();
    wx.request({
      url: `${HOST}v1/product/findRecommendProducts`,
      success: res => {
        let msg = res.data.data
        console.log(msg)
        let imgUrl = '';
        for (let i = 0; i < msg.length; i++) {
          imgUrl = msg[i].portalImg.split(',')[0]
          msg[i].portalImg = imgUrl
        }
        console.log(imgUrl)
        that.setData({
          msg
        })
      }
    })
  },
  goToYouLike(e) {
   
    wx.navigateTo({
      url: `../../detail/detail?id=${e.currentTarget.dataset.productid}`,
    })
  }
  ,
  getMore() {
    wx.switchTab({
      url: '../../home/home',
    })
  },
  getPrizeList()
  {
   let activityId = 1;
   let self = this;
    wx.request({
      url: HOST + 'v1/winrecord/findRecordList/' + app.userId + "," + activityId,
      method:"GET",
      success:function(res)
      {
        if (res.data.sysCode === 1)
        {
          console.log(res.data.data);
          self.setData({
            prizes:res.data.data.reverse()
          })
        }
      }
    })
  }
})